<?php
/**
 * @return
 * @author 朱乐斌
 * @date
 */
namespace app\api\model;

use think\Model;

class ReleasePositionModel extends Model
{
    protected $table = "gx_release_position";
    protected $hidden = ['qualifications_id'];
    public function EnterpriseIntroduce()
    {
        return $this->hasMany(EnterpriseIntroduce::class,'id','enterprise_introduce')->field('id,name');
    }

    public function EnterpriseList()
    {
        return $this->hasMany(EnterpriseModel::class,'id','enterprise_id')->field('id,name,phone');
    }

    public function QualificationsList()
    {
        return $this->hasMany(QualificationsModel::class,'id','qualifications_id')->field('id,name');
    }

    public static function getPostTypeList(array $data):bool
    {
        // 实例化模型并查出所有数据
        $model = new ReleasePositionModel();
        $model = $model->select();
        // 模型查询出分类 例：php
        $type = new PostTypeModel();
        // 查询出吗名字中有php的数据并循环出他们的id
        $type = $type->where('name','like','%'. $data['name'] .'%')->select();
        $typeId = [];
        foreach ($type as $item){
            $typeId[] = $item['id'];
        }
        $hasMatch = false;
        foreach ($typeId as $id)
        {
            $resume = $model->where('post_type_id',$id)->select();
            if ($resume) {
                $hasMatch = true;
                break;
            }
        }
        return $hasMatch;
    }

}

